<?php

class Application_Model_LoginModel
{
	public function authLogin($login,$senha){

		$registry = Zend_Registry::getInstance();
		$banco    = Zend_Db_Table::getDefaultAdapter();

		$registry->set('qative',$banco);

		$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('qative'),'usuario','USU_LOGIN','USU_SENHA','SHA1(?)');
		$authAdapter->setIdentity($login)->setCredential($senha);
		$result = $authAdapter->authenticate();

		if($result->isValid()){
			$auth = Zend_Auth::getInstance();
			$data = $authAdapter->getResultRowObject(null,'senha');
			$auth->getStorage()->write($data);
			return true;
		}		
	}
}

